/**  
* @Title: HouseController.java
* @Package com.house.service.controller
* @version V1.0  
*/ 
package com.hjb.service.controller.basic;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.hjb.service.annotation.LogInfo;
import com.hjb.service.annotation.LogType;
import com.hjb.service.basic.HouseService;
import com.hjb.service.controller.user.UserController;
import com.hjb.service.domain.HouseImage;
import com.hjb.service.domain.ThouseRoom;

/**
* @ClassName: HouseController
* @Description: TODO(房源基本信息)
* @author <a href="mailto:125671254@qq.com">Pan Xinwen</a>
* @date 2017年4月28日 下午4:02:26
*/
@RestController
@RequestMapping("/house/v1")
public class HouseController {
	
	private Logger log = LoggerFactory.getLogger(UserController.class);

	@Autowired
	private HouseService houseService;
	
	
	@LogInfo(logType=LogType.查询,operationContent="获取房源详情")
	@RequestMapping("getHomeDetails")
	@ResponseBody
	public Map<String,Object> getHomeDetails(String houseId){
		//房源信息
		ThouseRoom house = houseService.getHouseById(houseId);
		//房源展示图片
		List<HouseImage> hiList = houseService.getHouseImageByHouseId(house.getId());
		//查询公用家电信息
		List<Map<String,Object>> furnitureList= houseService.getHouseFurniture(house.getId());
		//查询房间设备
		List<Map<String,Object>> roomFurnitureList= houseService.getHouseRoomFurniture(houseId);
		//查询全部房间
		List<ThouseRoom> allRoom = houseService.getAllRoomByHouseId(house.getId());
		
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("house", house);
		map.put("hiList", hiList);
		map.put("furnitureList", furnitureList);
		map.put("roomFurnitureList", roomFurnitureList);
		map.put("allRoom", allRoom);
		
		return map;
		
	}
	
	@LogInfo(logType=LogType.查询,operationContent="初始化首页")
	@RequestMapping("indexHome")
	@ResponseBody
	public Map<String,Object> indexHome(HttpServletRequest request){
		
		return houseService.indexHome(request);
		
	}
}
